<?php
/**
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */

namespace App\Repository;

use App\model\BrokerRecords;
use App\model\user\UserSocialite;
use App\User;
use function foo\func;

class UserRepository
{
    public function getRecords($user_id){
        return BrokerRecords::where('user_id','=',$user_id)->orderBy('updated_at', 'desc')->paginate(10);
    }
    public function socialiteLogin(array $userInfo){//社会化登录
        $userSocialite= UserSocialite::firstOrCreate(['openid'=>$userInfo['openid']],['nickname'=>$userInfo['nickname'],'type'=>$userInfo['type'],'avatar'=>$userInfo['avatar']]);
       if($userSocialite->user_id!=''){

       } else{
           $user= User::create(['name'=>$userInfo['nickname'],'password'=>bcrypt('123456')]);
           $userSocialite->user_id=$user->id;
           $userSocialite->save();
       }
        \Auth::loginUsingId($userSocialite->user_id);
    }
}